package com.ruoyi.dynamic.controller.app;


import com.ruoyi.common.core.constant.constant.PathConstant;
import com.ruoyi.common.core.context.SecurityContextHolder;
import com.ruoyi.common.core.pojo.result.Pages;
import com.ruoyi.common.core.pojo.vo.BaseVO;
import com.ruoyi.common.core.pojo.vo.PageVO;
import com.ruoyi.common.core.pojo.vo.SingleVO;
import com.ruoyi.common.core.result.Result;
import com.ruoyi.dynamic.model.pojo.request.app.AppFamilySearchRequest;
import com.ruoyi.dynamic.model.pojo.result.app.AppFamilyResult;
import com.ruoyi.dynamic.service.IFamilyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "App-家族相关", description = "App-家族相关")
@RestController
@RequestMapping(PathConstant.APP_PATH + "family")
public class AppFamilyController {

    @Autowired
    private IFamilyService iFamilyService;


    @Operation(summary = "家族列表", description = "家族列表")
    @GetMapping("listPage")
    public PageVO<AppFamilyResult> listPage(AppFamilySearchRequest request) {
        Pages<AppFamilyResult> pages = iFamilyService.listPage(request, SecurityContextHolder.getUserId());
        return Result.page(pages);
    }

    @Operation(summary = "家族详情", description = "家族详情")
    @GetMapping("info")
    public SingleVO<AppFamilyResult> info(Long id) {
        AppFamilyResult result = iFamilyService.appInfo(id);
        return Result.single(result);
    }

    @Operation(summary = "家族删除", description = "家族删除")
    @GetMapping("del")
    public BaseVO del(Long id) {
        return Result.successOrFail(iFamilyService.removeById(id));
    }

}

